﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="pol_ylev_vastus", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(PolYlevVastus))]
    public class PolYlevVastusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IPolYlevVastus clazz;
        
        public PolYlevVastusSerializer(IPolYlevVastus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("kood");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Kood))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("teade");
            if (clazz.Teade!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Teade))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Teade");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("yv_kp");
            if (clazz.YvKp!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.YvKp))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : YvKp");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("jargm_yv");
            if (clazz.JargmYv!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.JargmYv))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : JargmYv");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("regmrk");
            if (clazz.Regmrk!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Regmrk))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Regmrk");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mark");
            if (clazz.Mark!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Mark))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Mark");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("vinkood");
            if (clazz.Vinkood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Vinkood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Vinkood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("otsus");
            if (clazz.Otsus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Otsus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Otsus");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "kood")) {
                goto kood;
            }
            else {
                if ((Reader.LocalName == "teade")) {
                    goto teade;
                }
                else {
                    if ((Reader.LocalName == "yv_kp")) {
                        goto yv_kp;
                    }
                    else {
                        if ((Reader.LocalName == "jargm_yv")) {
                            goto jargm_yv;
                        }
                        else {
                            if ((Reader.LocalName == "regmrk")) {
                                goto regmrk;
                            }
                            else {
                                if ((Reader.LocalName == "mark")) {
                                    goto mark;
                                }
                                else {
                                    if ((Reader.LocalName == "vinkood")) {
                                        goto vinkood;
                                    }
                                    else {
                                        if ((Reader.LocalName == "otsus")) {
                                            goto otsus;
                                        }
                                        else {
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        kood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_ylev_vastus>kood");
            }
            clazz.Kood = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("kood")).Value;
            goto START;
        teade:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_ylev_vastus>teade");
            }
            clazz.Teade = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("teade")).Value;
            goto START;
        yv_kp:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_ylev_vastus>yv_kp");
            }
            clazz.YvKp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("yv_kp")).Value;
            goto START;
        jargm_yv:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_ylev_vastus>jargm_yv");
            }
            clazz.JargmYv = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("jargm_yv")).Value;
            goto START;
        regmrk:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_ylev_vastus>regmrk");
            }
            clazz.Regmrk = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("regmrk")).Value;
            goto START;
        mark:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_ylev_vastus>mark");
            }
            clazz.Mark = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mark")).Value;
            goto START;
        vinkood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_ylev_vastus>vinkood");
            }
            clazz.Vinkood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("vinkood")).Value;
            goto START;
        otsus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_ylev_vastus>otsus");
            }
            clazz.Otsus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("otsus")).Value;
            goto START;
        }
    }
}
